<?php
class helper_form_radio extends system_view_helper_formElement {
	
	public function radio($name, $value, array $options, $attribs = null) {
		$info = $this->_getInfo($name, $value, $attribs);	
		$xhtml = array();
		$id = $info['id'];
		$value = $info['value'];
		$attr = $this->_htmlAttribs($info['attribs']);
		foreach($options AS $v => $label) {
			$_attr = $attr;
			$_id = $id . '-' . $v;
			if($value == $v) {
				$_attr .= 'checked="checked"';
			}
			
			$xhtml[] = '<input type="radio" name="' . $info['name'] . '" id="' . $_id . '" value="' . $v . '" ' . $_attr . 
					$this->getClosingBracket() . '<label for="' . $_id . '">' . $this->getView()->escape($label) . '</label>';
		}	
		return implode('', $xhtml);
	}
	
	
}